/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.mzk.oai.metadataRepository.cli.alephHarvest;

import cz.mzk.oai.metadataRepository.harvest.HarvestException;
import cz.mzk.oai.metadataRepository.harvest.marc21.MarcHarvester;
import cz.mzk.oai.metadataRepository.harvest.marc21.OAIHarvester;
import cz.mzk.oai.metadataRepository.metadata.DateStamp;
import cz.mzk.oai.metadataRepository.repository.AlephBase;
import cz.mzk.oai.metadataRepository.repository.Repository;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Martin Řehánek (rehan at mzk.cz)
 * @deprecated 
 */
public class OaiHarvester implements Harvester {

    private final URL oaiBaseUrl;
    private final Repository repository;
    private final File logFile;

    public OaiHarvester(URL oaiBaseUrl, Repository repository, File logFile) {
        this.oaiBaseUrl = oaiBaseUrl;
        this.repository = repository;
        this.logFile = logFile;
    }

    public void harvestAll(AlephBase base) throws IOException {
        harvest(base, null);
    }

    public void harvestFrom(AlephBase base, DateStamp from) throws IOException {
        harvest(base, from);
    }

    private void harvest(AlephBase alephBase, DateStamp from) throws IOException {
        MarcHarvester alephHarvester = new OAIHarvester(oaiBaseUrl, alephBase, repository, logFile.getAbsolutePath());
        try {
            alephHarvester.harvest(from, null);
        } catch (HarvestException ex) {
            Logger.getLogger(OaiHarvester.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void harvestBetween(AlephBase base, DateStamp from, DateStamp to) throws IOException {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
